import _Table from "antd/lib/table";
import _Input from "antd/lib/input";
import _Col from "antd/lib/col";
import _Button from "antd/lib/button";
import _Icon from "antd/lib/icon";
import _notification from "antd/lib/notification";
import _Modal from "antd/lib/modal";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _Row from "antd/lib/row";
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
import _Select from "antd/lib/select";
import _Form from "antd/lib/form";

function _templateObject() {
  var data = _taggedTemplateLiteral(["\n  .ant-form-item {\n    margin-bottom: 8px;\n  }\n"]);

  _templateObject = function _templateObject() {
    return data;
  };

  return data;
}

import React, { useState } from "react";
import styled from "styled-components";
import intl from "cpaas-front/lib/utils/intl";
import { Content, Header } from "../../../components/Page";
import { ButtonItems } from "./index.style";
import TableAction from "../../../components/TableAction"; // import operationIcon from "../../../../assets/components/svgs/operation.svg";

var Item = _Form.Item;
var Option = _Select.Option;
var StyledRow = styled(_Row)(_templateObject());

var TablePreview = function TablePreview(props) {
  var _useState = useState(false),
      _useState2 = _slicedToArray(_useState, 2),
      showMore = _useState2[0],
      setShowMore = _useState2[1];

  var handleDelete = function handleDelete() {
    // 打开Modal
    _Modal.confirm({
      title: "确定删除吗？"
    });
  };

  var handlePublish = function handlePublish() {
    _Modal.confirm({
      title: "是否发布",
      onOk: function onOk() {
        return _notification.success({
          message: "发布成功",
          duration: 3
        });
      },
      onCancel: function onCancel() {
        return _notification.info({
          message: "取消发布",
          duration: 3
        });
      }
    });
  };

  var tableActionOptions = [{
    key: "1",
    text: "编辑",
    icon: "edit",
    action: function action() {
      return props.onNext();
    }
  }, {
    key: "2",
    text: "发布",
    icon: "cloud-upload",
    action: handlePublish
  }, {
    key: "3",
    text: "删除",
    icon: "delete",
    subOptions: [{
      key: "3-1",
      text: "删除远端",
      icon: "delete",
      action: handleDelete
    }, {
      key: "3-2",
      text: "删除本地",
      icon: "delete",
      action: handleDelete
    }]
  }];
  var tableProps = {
    dataSource: Array.from({
      length: 500
    }).map(function (v, i) {
      return {
        type: "\u7CFB\u7EDF\u516C\u544A".concat(i),
        title: "\u8FD9\u662F\u6807\u9898\u6587\u6848\u8FD9\u662F\u6807\u9898\u6587\u6848\u8FD9\u662F\u6807\u9898\u6587\u6848\u8FD9\u662F\u6807\u9898\u6587\u6848\u8FD9\u662F\u6807\u9898\u6587\u6848\u8FD9\u662F\u6807\u9898\u6587\u6848".concat(i),
        publisher: "\u7BA1\u7406\u5458".concat(i),
        status: "\u5DF2\u53D1\u5E03".concat(i),
        publishTime: "2019-8-15".concat(i),
        action: "...".concat(i)
      };
    }),
    columns: [{
      title: intl.get("cpaas.cpaasTheme.page.annoType").d("公告类型"),
      dataIndex: "type",
      key: "type"
    }, {
      title: intl.get("cpaas.cpaasTheme.page.annoTitle").d("公告标题"),
      dataIndex: "title",
      key: "title"
    }, {
      title: intl.get("cpaas.cpaasTheme.page.publisher").d("发布人"),
      dataIndex: "publisher",
      key: "publisher"
    }, {
      title: intl.get("cpaas.cpaasTheme.page.annoStatus").d("公告状态"),
      dataIndex: "status",
      key: "status"
    }, {
      title: intl.get("cpaas.cpaasTheme.page.publishTime").d("发布时间"),
      dataIndex: "publishTime",
      key: "publishTime"
    }, {
      title: "操作",
      dataIndex: "action",
      render: function render() {
        return React.createElement(TableAction, {
          options: tableActionOptions
        });
      },
      key: "action"
    }],
    pagination: {
      pageSize: 10,
      totalCount: 500
    },
    rowKey: function rowKey(record) {
      return record.type;
    }
  };
  return React.createElement(React.Fragment, null, React.createElement(Header, {
    title: intl.get("cpaas.cpaasTheme.page.tablePreview").d("表格预览"),
    onBack: props.onBack,
    hideBackBtn: true
  }, React.createElement(_Button, {
    onClick: props.onExit,
    type: "primary"
  }, React.createElement(_Icon, {
    type: "logout"
  }), intl.get("cpaas.cpaasTheme.page.exitPreview").d("退出预览"))), React.createElement(Content, null, React.createElement(StyledRow, {
    type: "flex",
    gutter: 24,
    align: "bottom"
  }, React.createElement(_Col, {
    span: 5
  }, React.createElement(Item, {
    label: intl.get("cpaas.cpaasTheme.page.annoTitle").d("公告标题")
  }, React.createElement(_Select, {
    defaultValue: "1"
  }, React.createElement(Option, {
    value: "1"
  }, "\u9009\u98791"), React.createElement(Option, {
    value: "2"
  }, "\u9009\u98792"), React.createElement(Option, {
    value: "3"
  }, "\u9009\u98793"), React.createElement(Option, {
    value: "4"
  }, "\u9009\u98794")))), React.createElement(_Col, {
    span: 5
  }, React.createElement(Item, {
    label: intl.get("cpaas.cpaasTheme.page.companyName").d("公司名称")
  }, props.form.getFieldDecorator("name")(React.createElement(_Input, null)))), React.createElement(_Col, {
    span: 5
  }, React.createElement(Item, {
    label: intl.get("cpaas.cpaasTheme.page.deptName").d("部门名称")
  }, props.form.getFieldDecorator("dept")(React.createElement(_Input, null)))), React.createElement(_Col, {
    span: 7
  }, React.createElement(ButtonItems, null, React.createElement(_Button, {
    onClick: function onClick() {
      return setShowMore(function (v) {
        return !v;
      });
    }
  }, intl.get("cpaas.cpaasTheme.page.more").d("更多")), React.createElement(_Button, null, intl.get("cpaas.cpaasTheme.page.reset").d("重置")), React.createElement(_Button, {
    type: "primary"
  }, intl.get("cpaas.cpaasTheme.page.query").d("查询"))))), showMore && React.createElement(_Row, {
    type: "flex",
    gutter: 24,
    align: "bottom"
  }, React.createElement(_Col, {
    span: 5
  }, React.createElement(Item, {
    label: "".concat(intl.get("cpaas.cpaasTheme.page.query").d("查询"), " 1")
  }, React.createElement(_Input, null))), React.createElement(_Col, {
    span: 5
  }, React.createElement(Item, {
    label: "".concat(intl.get("cpaas.cpaasTheme.page.query").d("查询"), " 2")
  }, React.createElement(_Input, null)))), React.createElement(_Table, tableProps)));
};

TablePreview.defaultProps = {
  onBack: function onBack() {},
  onNext: function onNext() {},
  onExit: function onExit() {}
};
export default _Form.create()(TablePreview);
